package com.netty.encodedecode.protol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 编码器
 *
 * @auther: cc.ly
 * @date: 2019/1/13/013
 */

public class PersonProtolEncode extends MessageToByteEncoder<PersonProtol> {
    @Override
    protected void encode(ChannelHandlerContext ctx, PersonProtol msg, ByteBuf out) throws Exception {
        out.writeInt(msg.getLength());
        out.writeBytes(msg.getContent());
    }
}
